// pages/driver/sign/sign.js
const handler = require("../../../utils/function.js");
var app = getApp(),
  api = require("../../../api.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    sign:''
  },
  //获取备注信息
  getMasker:function(e){
    console.log(e)
    var masker=e.detail.value;
    this.setData({ masker})
  },
  deleteBtn:function(e){
    if (!this.data.masker){
      wx.showToast({
        title: '请输入取消原因',
        icon:'none'
      })
      return false
    }
    let that=this;
    console.log(e)
    var formid = e.detail.formId;
    wx.showLoading({})
    app.request({
      url: api.order.driver_cancel_order,
      method: 'post',
      data: {
        order_no: that.data.order_no,
        apply_remarks: that.data.masker,
        formid: formid
      },
      success:function(res){
        wx.hideLoading()
        console.log(res)
        if(res.code==1){
          wx.showToast({
            title: res.msg, mask: true,icon:'none'
          })
          app.gateway(that.data.order_no, 5, that.data.masker)
          setTimeout(() => {
            wx.reLaunch({
                url: '/pages/index/index'
            });
          }, 1000)
        }else{
          wx.showToast({
            title: res.msg, mask: true, icon: 'none'
          })
        }
      },
    })
  },
  
  /**
   * 
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // 获取优惠券
    if (options.uid) {
      app.shareCouponsMessage(options.uid)
    }
    // 获取订单id
    if (options.order_no){
      this.setData({ order_no: options.order_no})
    }else{
      wx.showToast({
        title: '获取用户名错误',
      })
    }
  },
  // 用户分享
  onShareAppMessage: function () {
    let title = app.shareAppMessage().title;
    let imageUrl = app.shareAppMessage().imageUrl;
    let desc = app.shareAppMessage().desc;
    let path = app.shareAppMessage().path;
    console.log(app.shareAppMessage())
    return {
      title: title,
      imageUrl: imageUrl,
      desc: desc,
      path: path,
    }
  },
  
})